package com.xianniu.ltc.service.impl;

import cn.devezhao.persist4j.Query;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.Application;
import com.rebuild.core.UserContextHolder;
import com.rebuild.core.privileges.UserService;
import com.rebuild.core.service.dashboard.charts.ChartData;
import com.rebuild.core.service.dashboard.charts.ChartsFactory;
import com.rebuild.core.support.general.DataListBuilder;
import com.rebuild.core.support.general.DataListBuilderImpl;
import com.xianniu.ltc.model.po.report.ChartCommonPermissionsPO;
import com.xianniu.ltc.model.vo.CashTransferSchemesVO;
import com.xianniu.ltc.model.vo.StatisticsXYVO;
import com.xianniu.ltc.model.vo.statistics.StatisticsYVO;
import com.xianniu.ltc.service.AppHomeService;
import com.xianniu.ltc.service.CustomizedService;
import com.xxl.sso.core.entity.ReturnT;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.w3c.dom.stylesheets.LinkStyle;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CompletableFuture;

/**
 * @ClassName AppHomeImpl
 * @Author MengGang
 * @Date 2022/6/19 9:06
 * @ModifyDate 2022/6/19 9:06
 * @Version 1.0
 */
@Slf4j
@Service
public class AppHomeImpl implements AppHomeService {
    @Resource
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;

    @Autowired
    private CustomizedService customizedService;

    @Override
    public JSONObject v1HomeInfo(ChartCommonPermissionsPO po )  throws Exception{
        JSONObject resultJson = new JSONObject();
        long startTime = System.currentTimeMillis();

        // 当前登录用户
        final ID userId = UserContextHolder.getUser();
        // 获取租户信息
        final String tenantCode = UserContextHolder.getTenant();

        // 线索数
        CompletableFuture<Void> leadCount_v = homeInfoLeadCount(userId, tenantCode, resultJson);
        // 商机数(不包括赢单，输单)
        CompletableFuture<Void> shangJi_v = homeInfoNicheCount(userId, tenantCode, resultJson);
        // 客户数
        CompletableFuture<Void> kehushu_v = homeInfoAccountCount(userId, tenantCode, resultJson);
        // 合同数(不包含已作废)
        CompletableFuture<Void> hetongshu_v = homeInfoContractCount(userId, tenantCode, resultJson);
        // 回款计划-未收款的计划收款金额的汇总
        CompletableFuture<Void> jihuashoukuanjine_v = homeInfoPlanMoneyCount(userId, tenantCode, resultJson);
        // 查询赢率漏斗
        CompletableFuture<Void> yingLvJson = homeInfoWinRateCount(userId, tenantCode, resultJson);
        // 地域统计 top 10
        CompletableFuture<Void> top10City = homeInfoNowYearCityTop(userId, tenantCode, resultJson);
        // 客户统计 top 10
        CompletableFuture<Void> top10KeHu = homeInfoNowYearKeHuTop(userId, tenantCode, resultJson);
        // 本年销售部门签约额统计
        CompletableFuture<Void> xiaoShou = homeInfoNowYearXiaoShou(userId, tenantCode, resultJson);
        // 本年 周 签约额统计
        CompletableFuture<Void> actualWeek = homeInfoNowYearWeek(userId, tenantCode, resultJson);
        // 本年 月 和 季 签约额统计
        CompletableFuture<Void> actualMonthAndQuarter = homeInfoNowYearMonthAndQuarter(userId, tenantCode, resultJson);
        // 历史未回款统计
        CompletableFuture<Void> historyWeiShouKuan = homeInfoHistoryWeiShouKuan(userId, tenantCode, resultJson);
        // 本年 月和季 回款额统计
        CompletableFuture<Void> huiKuanMonthAndQuarter =  homeInfoNowYearHuiKuanByMonthAndQuarter(userId, tenantCode, resultJson);
        // 本年 周 回款额统计
        CompletableFuture<Void> huiKuanWeek =  homeInfoNowYearHuiKuanByWeek(userId, tenantCode, resultJson);

        CompletableFuture.allOf(
                leadCount_v,
                shangJi_v,
                kehushu_v,
                hetongshu_v,
                jihuashoukuanjine_v,
                yingLvJson,
                top10City,
                top10KeHu,
                xiaoShou,
                actualWeek,
                actualMonthAndQuarter,
                historyWeiShouKuan,
                huiKuanMonthAndQuarter,
                huiKuanWeek
        ).get();
        long endTime = System.currentTimeMillis();
        log.info("统计项目报表耗时:{}ms", (endTime - startTime));
        log.info("查询结果{}", JSONObject.toJSONString(resultJson));
        return resultJson;
    }

    /**
     * APP首页-查询私海所属线索数
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoLeadCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String sql0 = String.format("select count(owningUser) from sihaixiansuo where tenantCode = ? and owningUser = ?");
            Query leadCount = Application.createQueryNoFilter(sql0)
                    .setParameter(1, tenantCode)
                    .setParameter(2, userId);
            Object[] result0 = leadCount.unique();
            Object leadCount_v = Objects.isNull(result0[0]) ? 0:result0[0];

            resultJson.put("xianSuoShu", leadCount_v);
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * APP首页-查询商机数
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNicheCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String sql = String.format("select count(owningUser) from rbshangji4 where tenantCode = ? and owningUser = ? and shangjijieduanyinglv not in ('019-017a613777930008','019-017a61371dfc0007')");
            Query shangJiShu = Application.createQueryNoFilter(sql)
                    .setParameter(1, tenantCode)
                    .setParameter(2, userId);
            Object[] result1 = shangJiShu.unique();
            Object shangJi_v = Objects.isNull(result1[0]) ? 0:result1[0];
            resultJson.put("shangJiShu", shangJi_v);
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * APP首页-查询客户数
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoAccountCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String sql = String.format("select count(owningUser) from sihaikehu where tenantCode = ? and owningUser = ?");
            Query kehushu = Application.createQueryNoFilter(sql)
                    .setParameter(1, tenantCode)
                    .setParameter(2, userId);
            Object[] result2 = kehushu.unique();
            Object kehushu_v = Objects.isNull(result2[0]) ? 0:result2[0];
            resultJson.put("keHuShu", kehushu_v);
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * APP首页-查询合同数
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoContractCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String sql = String.format("select count(owningUser) from rbhetong0 where tenantCode = ? and owningUser = ? and hetongjieduan <> '019-0179930e6def01fa'");
            Query hetongshu = Application.createQueryNoFilter(sql)
                    .setParameter(1, tenantCode)
                    .setParameter(2, userId);
            Object[] result3 = hetongshu.unique();
            Object hetongshu_v = Objects.isNull(result3[0]) ? 0:result3[0];
            resultJson.put("heTongShu", hetongshu_v);
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * APP首页-计划收款金额
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoPlanMoneyCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String sql = String.format("select sum(jihuashoukuanjine) from huikuanjihua where tenantCode = ? and owningUser = ? and huikuanzhuangtai  = '012-01760df25cf30039'");
            Query jihuashoukuanjine = Application.createQueryNoFilter(sql)
                    .setParameter(1, tenantCode)
                    .setParameter(2, userId);
            Object[] result4 = jihuashoukuanjine.unique();
            Object jihuashoukuanjine_v = Objects.isNull(result4[0]) ? 0:new BigDecimal(result4[0].toString()).setScale(2,BigDecimal.ROUND_HALF_UP);
            resultJson.put("daiHuiKuanJinE", jihuashoukuanjine_v);
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * APP首页-计划收款金额
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoWinRateCount(ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            String chartId = "017-017767c92a570cf0";
            Map<String, Object> paramMap = new HashMap<>();
            paramMap.put("id", chartId);
            JSON yingLvJson = null;
            UserContextHolder.setUser(userId);
            UserContextHolder.setTenant(tenantCode);
            try{
                ChartData chart = ChartsFactory.create(ID.valueOf(chartId), tenantCode);
                yingLvJson = chart.setExtraParams(paramMap).build(tenantCode);
            }catch (Exception e){
                e.printStackTrace();
                log.info("没有商机权限:{}",e.getMessage());
                JSONObject jso = new JSONObject();
                jso.put("data", new String[0]);
                yingLvJson = jso;
            }
            log.info("输出赢率漏斗：{}", yingLvJson);
            resultJson.put("yingLv", ((JSONObject) yingLvJson).get("data"));
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 地域统计 top 10
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearCityTop( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入top10===1 地域");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO top10City =  customizedService.queryNowYearCityTop(po);
                log.info("城市本年签约额top10==={}", top10City);
                resultJson.put("top10City", top10City);
            }catch (Exception e){
                log.info(e.getMessage());
                StatisticsXYVO top10City = new StatisticsXYVO();
                StatisticsYVO yVo = new StatisticsYVO();
                List xVo = new ArrayList();
                top10City.setXAxis(xVo);
                top10City.setYyyAxis(yVo);
                resultJson.put("top10City", top10City);
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 客户统计 top 10
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearKeHuTop( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入top10===2 客户");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO top10KeHu = customizedService.queryNowYearKeHuTop( po );
                log.info("客户本年签约额top10==={}", top10KeHu);
                resultJson.put("top10KeHu", top10KeHu);
            }catch (Exception e){
                log.info(e.getMessage());
                StatisticsXYVO top10KeHu = new StatisticsXYVO();
                StatisticsYVO yVo = new StatisticsYVO();
                List xVo = new ArrayList();
                top10KeHu.setXAxis(xVo);
                top10KeHu.setYyyAxis(yVo);
                resultJson.put("top10KeHu", top10KeHu);
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 销售销售部门-本年签约额-统计
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearXiaoShou( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入===3 销售部门");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO xiaoShou = customizedService.queryNowYearXiaoShouBuMen( po );
                log.info("销售部门本年签约额==={}", xiaoShou);
                resultJson.put("xiaoShou", xiaoShou);
            }catch (Exception e){
                log.info(e.getMessage());
                StatisticsXYVO xiaoShou = new StatisticsXYVO();
                StatisticsYVO yVo = new StatisticsYVO();
                List xVo = new ArrayList();
                xiaoShou.setXAxis(xVo);
                xiaoShou.setYyyAxis(yVo);
                resultJson.put("xiaoShou", xiaoShou);
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 本年-周-统计
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearWeek( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入===4 本年签约额统计 周");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO actualWeek = customizedService.queryNowYearWeek( po );
                log.info("本年签约额统计: 周==={}", actualWeek);
                resultJson.put("actualWeek", actualWeek);
            }catch (Exception e){
                log.info(e.getMessage());
                StatisticsXYVO actualWeek = new StatisticsXYVO();
                StatisticsYVO yVo = new StatisticsYVO();
                List xVo = new ArrayList();
                actualWeek.setXAxis(xVo);
                actualWeek.setYyyAxis(yVo);
                resultJson.put("actualWeek", actualWeek);
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 本年签约额统计-月+季度
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearMonthAndQuarter( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入===8 本年签约额统计 月和季");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                Map<String, StatisticsXYVO> actualMonthAndQuarter = customizedService.queryNowYearMonthAndQuarter( po );
                log.info("本年签约额统计-月 和 季=== {}", JSON.toJSON(actualMonthAndQuarter));

                resultJson.put("actualMonth", actualMonthAndQuarter.get("month"));
                resultJson.put("actualQuarter", actualMonthAndQuarter.get("quarter"));
            }catch (Exception e){
                log.info(e.getMessage());

                // 月度
                List<String> yMonthData = new ArrayList<String>();
                List xMonthData = new ArrayList();
                for ( int i=1; i<=12; i++ ){
                    BigDecimal monthValue = BigDecimal.ZERO;
                    xMonthData.add(i+"月");
                    yMonthData.add(monthValue.toString());
                }

                // 设置Y轴数据
                StatisticsYVO monthYVo = new StatisticsYVO();
                monthYVo.setData( yMonthData );
                monthYVo.setName( "本年签约额统计" );
                // 周统计数据
                StatisticsXYVO huiKuanMonth = new StatisticsXYVO();

                huiKuanMonth.setXAxis(xMonthData);
                huiKuanMonth.setYyyAxis(monthYVo);

                // 季度
                List<String> yQuarterData = new ArrayList<String>();
                List xQuarterData = new ArrayList();
                Map<Integer, String> numberName = new HashMap<Integer, String>();
                numberName.put(1, "一");
                numberName.put(2, "二");
                numberName.put(3, "三");
                numberName.put(4, "四");
                for (int i=1; i<=4; i++ ){
                    xQuarterData.add( "第"+numberName.get(i)+"季度");
                    BigDecimal quarterValue = BigDecimal.ZERO;
                    yQuarterData.add(quarterValue.toString());
                }
                // 设置Y轴数据
                StatisticsYVO quarterYVo = new StatisticsYVO();
                quarterYVo.setData( yQuarterData );
                quarterYVo.setName( "本年签约额统计" );
                // 周统计数据
                StatisticsXYVO huiKuanQuarter = new StatisticsXYVO();

                huiKuanQuarter.setXAxis(xQuarterData);
                huiKuanQuarter.setYyyAxis(quarterYVo);


                Map<String, StatisticsXYVO> actualMonthAndQuarter = new HashMap<String, StatisticsXYVO>();
                resultJson.put("actualMonth", huiKuanMonth );
                resultJson.put("actualQuarter", huiKuanQuarter );
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 历史累计应收未收款统计
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoHistoryWeiShouKuan( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {
            try {
                log.info("进入===5 历史累计应收未收款统计");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO historyWeiShouKuan = customizedService.queryHistoryWeiShouKuan( po );
                log.info("历史累计应收未收款统计==={}", historyWeiShouKuan);
                resultJson.put("historyWeiShouKuan", historyWeiShouKuan);
            }catch (Exception e) {
                log.info(e.getMessage());
                StatisticsXYVO historyWeiShouKuan = new StatisticsXYVO();
                StatisticsYVO yVo = new StatisticsYVO();
                List xVo = new ArrayList();
                historyWeiShouKuan.setXAxis(xVo);
                historyWeiShouKuan.setYyyAxis(yVo);
                resultJson.put("historyWeiShouKuan", historyWeiShouKuan);
            }

        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 本年回款统计 月和季
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearHuiKuanByMonthAndQuarter( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {

            try {
                log.info("进入===6 本年回款统计 月");
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                Map<String, StatisticsXYVO> huiKuanMonthAndQuarter = customizedService.selectMonthCashTransferSchemesData( po );
                log.info("本年回款统计-月 和 季=== {}", JSON.toJSON(huiKuanMonthAndQuarter));
                resultJson.put("huiKuanMonth", huiKuanMonthAndQuarter.get("month"));
                resultJson.put("huiKuanQuarter", huiKuanMonthAndQuarter.get("quarter"));
            }catch (Exception e){
                log.info(e.getMessage());

                // 月度
                List<String> yMonthData = new ArrayList<String>();
                List xMonthData = new ArrayList();
                for ( int i=1; i<=12; i++ ){
                    BigDecimal monthValue = BigDecimal.ZERO;
                    xMonthData.add(i+"月");
                    yMonthData.add(monthValue.toString());
                }
                // 设置Y轴数据
                StatisticsYVO monthYVo = new StatisticsYVO();
                monthYVo.setData( yMonthData );
                monthYVo.setName( "本年回款统计" );
                // 周统计数据
                StatisticsXYVO huiKuanMonth = new StatisticsXYVO();

                huiKuanMonth.setXAxis(xMonthData);
                huiKuanMonth.setYyyAxis(monthYVo);

                // 季度
                List<String> yQuarterData = new ArrayList<String>();
                List xQuarterData = new ArrayList();
                Map<Integer, String> numberName = new HashMap<Integer, String>();
                numberName.put(1, "一");
                numberName.put(2, "二");
                numberName.put(3, "三");
                numberName.put(4, "四");
                for (int i=1; i<=4; i++ ){
                    xQuarterData.add( "第"+numberName.get(i)+"季度");
                    BigDecimal quarterValue = BigDecimal.ZERO;
                    yQuarterData.add(quarterValue.toString());
                }
                // 设置Y轴数据
                StatisticsYVO quarterYVo = new StatisticsYVO();
                quarterYVo.setData( yQuarterData );
                quarterYVo.setName( "本年回款统计" );
                // 周统计数据
                StatisticsXYVO huiKuanQuarter = new StatisticsXYVO();

                huiKuanQuarter.setXAxis(xQuarterData);
                huiKuanQuarter.setYyyAxis(quarterYVo);


                Map<String, StatisticsXYVO> huiKuanMonthAndQuarter = new HashMap<String, StatisticsXYVO>();
                resultJson.put("huiKuanMonth", huiKuanMonth );
                resultJson.put("huiKuanQuarter", huiKuanQuarter );
            }
        }, threadPoolTaskExecutor);
        return salesContract;
    }

    /**
     * 本年回款统计-周
     * @param userId
     * @param tenantCode
     * @param resultJson
     * @return
     */
    private CompletableFuture<Void> homeInfoNowYearHuiKuanByWeek( ID userId, String tenantCode, JSONObject resultJson ){
        CompletableFuture<Void> salesContract = CompletableFuture.runAsync(() -> {

            try {
                // TODO
                UserContextHolder.setUser(userId);
                UserContextHolder.setTenant(tenantCode);
                ChartCommonPermissionsPO po = new ChartCommonPermissionsPO();
                po.setTenantCode(UserContextHolder.getTenant());
                StatisticsXYVO huiKuanWeek = customizedService.selectWeekCashTransferSchemesData( po );
                log.info("本年回款统计-周=== {}", JSON.toJSON(huiKuanWeek));
                resultJson.put("huiKuanWeek", huiKuanWeek);
            }catch (Exception e){
                log.info(e.getMessage());
                List<String> yWeekData = new ArrayList<String>();
                // 设置Y轴数据
                StatisticsYVO weekYVo = new StatisticsYVO();
                weekYVo.setData( yWeekData );
                weekYVo.setName( "本年回款统计" );
                // 周统计数据
                StatisticsXYVO huiKuanWeek = new StatisticsXYVO();
                List xWeekData = new ArrayList();
                huiKuanWeek.setXAxis(xWeekData);
                huiKuanWeek.setYyyAxis(weekYVo);
                resultJson.put("huiKuanWeek", huiKuanWeek);
            }

        }, threadPoolTaskExecutor);
        return salesContract;
    }



}
